package com.longbig.multifunction.controller;

import com.longbig.multifunction.dto.GecAccountInfo;
import com.longbig.multifunction.helper.ExcelHelper;
import com.longbig.multifunction.helper.ExcelUtil;
import com.longbig.multifunction.service.SyncGecProjectRegInfoServcie;
import com.longbig.multifunction.service.SyncProjectPowerInfoService;
import com.longbig.multifunction.service.SysGeoAccountInfoService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.FileInputStream;
import java.io.InputStream;
import java.util.List;

/**
 * @author Administrator
 * @date 2024/6/8 14:24
 * @description
 */
@RestController
@Slf4j
public class SyncController {

    @Autowired
    private SysGeoAccountInfoService sysGeoAccountInfoService;

    @Autowired
    private SyncGecProjectRegInfoServcie syncGecProjectRegInfoServcie;

    @Autowired
    private SyncProjectPowerInfoService syncProjectPowerInfoService;

    @GetMapping("/dealAccountInfoExcelBatch")
    public Boolean dealAccountInfoExcelBatch() throws Exception {
        File file = new File("D:\\出差绿证项目\\清洗数据\\数据清洗导入\\数据清洗导入\\全周期账户信息.xlsx");
        InputStream inputStream = new FileInputStream(file);
        List<GecAccountInfo> gecAccountInfoList = ExcelHelper.readExcel(inputStream, GecAccountInfo.class, 0);
        log.info("dealAccountInfoExcelBatch 总数：{}", gecAccountInfoList.size());
        boolean flag = sysGeoAccountInfoService.importAccountInfoBatch(gecAccountInfoList);
        return flag;
    }

    @GetMapping("/pushRegInfoList")
    public void pushRegInfoList() throws Exception {
        syncGecProjectRegInfoServcie.pushData();
    }

    @GetMapping("/pushPowerInfoList")
    public void pushPowerInfoList() throws Exception {
        syncProjectPowerInfoService.pushData();
    }


}
